package management;

import java.util.ArrayList;
import java.util.Random;

import dao.*;

public class ShuJu {

	public ShuJu() {
		
		User user=new User ();
		String str="name";
        UserDao userDao = DaoFactory.getUserDaoInstance();
		for(int i=1;i<=100;i++)
		{
			user.setId(i);
			user.setUsername(str+i);
			user.setPassword(str+i);
			user.setMoney(999);
			user.setTelNum("123");
			ArrayList<Integer> list = new ArrayList<Integer>();
            Random random = new Random();
            int j = 0, num = 0;
            while (j < 7) {
                    num = random.nextInt(35) + 1;
                    if (!list.contains(num)) {
                            list.add(num);
                    } else continue;
                    j++;
            }
            int num1=list.remove(0);
            int num2=list.remove(0);
            int num3=list.remove(0);
            int num4=list.remove(0);
            int num5=list.remove(0);
            int num6=list.remove(0);
            int num7=list.remove(0);
            
            String number=num1+" "+num2+" "+num3+" "+num4+" "+num5+" "+num6+" "+ num7 + " " + "1";
            user.setNum(number);
            try {
				userDao.Insert(user);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
		
		}
		
	}
	
